package com.clearliang.mobframe.utils;

import cn.sharesdk.framework.Platform;
import cn.sharesdk.framework.PlatformActionListener;
import cn.sharesdk.framework.ShareSDK;

/**
 * Created by ClearLiang on 2019/1/10
 * <p>
 * Function :三方登录工具类
 */
public class ThirdLoginUtil {
    private static ThirdLoginUtil instance;

    private ThirdLoginUtil() {
    }

    public static ThirdLoginUtil getInstance() {
        if (instance == null) {
            synchronized (ThirdLoginUtil.class) {
                if (instance == null) {
                    instance = new ThirdLoginUtil();
                }
            }
        }
        return instance;
    }

    public void getAuthorization(String type, PlatformActionListener platformActionListener) {
        Platform platform = ShareSDK.getPlatform(type);
        platform.setPlatformActionListener(platformActionListener);
        if (platform.isAuthValid()) {
            platform.removeAccount(true);
        }
        platform.SSOSetting(false);
        platform.authorize();
    }

}
